﻿@using viBook.Models
@model IEnumerable<ReportComment>
@{
    ViewBag.Title = "Comment Report";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
@(Html.Telerik().Grid(Model)
               .Name("report-comment")
               .DataKeys(keys => keys.Add(c => c.Id))
               .Columns(columns =>
                            {
                                columns.Bound(c => c.Id).Width(100);
                                columns.Bound(c => c.ReportedDate).Format("{0:dd/MM/yyyy}").Width(120);
                                columns.Bound(c => c.Id)
                                    .ClientTemplate(string.Format("<a class='t-button' href='javascript:approve(<#= Id #>)'>Approve</a>"))
                                    .Title("Approve");
                                columns.Command(c =>
                                                    {
                                                        c.Delete();
                                                        c.Edit();
                                                    });
                            })
               .DataBinding(dataBinding =>
                                {
                                    dataBinding.Server().Select("CommentReport", "Admins");
                                    dataBinding.Ajax().Select("CommentReportAjax", "Admins").Enabled(true);
                                    dataBinding.Ajax().Delete("CommentReportAjax", "Admins").Enabled(true);
                                })
                .Scrollable()
                .Sortable()
                .Pageable()
                .Filterable()
                .Footer(true)
        )
<script type="text/javascript">
    function approve(id) {
        $.ajax({
            url: '@Url.Action("CommentReport", "Admins")',
            type: 'POST',
            data: { id: id },
            contentType: 'APPLICATION/JSON',
            success: function (result) {
                if (result.success) {

                } else {
                    alert(result.message);
                }
            }
        });
    }
</script>
